#include<iostream>
#include<cstring>
using namespace std;
const int N = 1e5 + 10;
int arr[N], q[N];
int n;
int main()
{
	while (cin >> n) {
		memset(arr, 0, sizeof(arr));
		memset(q, 0, sizeof(q));
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int k = 0;
			while (k < cnt && q[k] < arr[i]) {
				k++;
			}
			q[k] = arr[i];
			if (k == cnt) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}